package mo.offer_special;

public class L020 {

    public int countSubstrings(String s) {
        int n = s.length();
        int ans = 0;
        for (int i = 0; i < 2 * n - 1; i++) {
            int l = i / 2;
            int r = i / 2 + (i % 2);
            while (l>=0 && r<n && l<=r && s.charAt(l) == s.charAt(r)) {
                l--;
                r++;
                ans++;
            }
        }
        return ans;
    }


    public static void main(String[] args) {
        L020 test = new L020();
        System.out.println(test.countSubstrings("abc"));
    }

}
